********************************************************************************
*** Role Model or Role Expansion? -- Replication Code **************************
********************************************************************************
*** Contact: Kevin Koehler, k.koehler@fsw.leidenuniv.nl ************************
********************************************************************************

********************************************************************************
***Graphs***********************************************************************
********************************************************************************

set scheme lean2
graph set window fontface "Times New Roman"

*** Figure 1 *******************************************************************
*** Data from different waves of Arab Barometer ********************************

preserve
clear
set obs 4
gen all=.
gen tunisia=.
gen wave=""
replace all=76.3 in 1
replace tunisia=92.8 in 1
replace wave="AB2 (2010-11)" in 1
replace all=75.9 in 2
replace tunisia=84.7 in 2
replace wave="AB3 (2012-14)" in 2
replace all=81.9 in 3
replace tunisia=94 in 3
replace wave="AB4 (2016-17)" in 3
replace all=75.3 in 4
replace tunisia=90.2 in 4
replace wave="AB5 (2018)" in 4
graph bar all tunisia, over(wave) ///
bar(1, bcolor(black)) ///
bar(2, bcolor(black*.5)) ///
legend(pos(6) col(2) order( ///
1 "All" ///
2 "Tunisia")) ///
blabel(bar) ///
ytitle("Percent")
restore

***Figure 2 ********************************************************************
preserve
replace MilFightTerror=MilFightTerror*100
replace OfficersServeInGov= OfficersServeInGov*100
replace MilitaryPolicePolProtests= MilitaryPolicePolProtests*100
replace MilitaryPoliceEcoProtests= MilitaryPoliceEcoProtests*100
replace MilitaryForeignPeaceKeeping= MilitaryForeignPeaceKeeping*100

graph set window fontface "Times New Roman"
graph bar MilFightTerror ///
OfficersServeInGov ///
MilitaryPolicePolProtests ///
MilitaryPoliceEcoProtests ///
MilitaryForeignPeaceKeeping, ///
legend (pos(6) col(2) order( ///
1 "Fighting Terror" ///
2 "Serving in Government" ///
3 "Police Political Protests" ///
4 "Police Economic Protests" ///
5 "Peacekeeping")) ///
bar(1, color(black*1)) ///
bar(2, color(black*.8)) ///
bar(3, color(black*.6)) ///
bar(4, color(black*.4)) ///
bar(5, color(black*.2)) ///
bargap(5) blabel(bar, format(%8.1f)) ///
ytitle("Percent agree or strongly agree") 
restore


***Figure 3*********************************************************************

graph set window fontface "Times New Roman"

tab o_officers, missing generate(off)
tab o_pprotest, missing generate(pprotest)
tab o_eprotest, missing generate(eprotest)

label var off1 "Strongly disagree"
label var off2 "Disagree"
label var off3 "Agree"
label var off4 "Strongly agree"
label var off5 "Missing"
label var pprotest1 "Strongly disagree"
label var pprotest2 "Disagree"
label var pprotest3 "Agree"
label var pprotest4 "Strongly agree"
label var pprotest5 "Missing"
label var eprotest1 "Strongly disagree"
label var eprotest2 "Disagree"
label var eprotest3 "Agree"
label var eprotest4 "Strongly agree"
label var eprotest5 "Missing"

replace off1=off1*100
replace off2=off2*100
replace off3=off3*100
replace off4=off4*100
replace off5=off5*100
replace pprotest1=pprotest1*100
replace pprotest2=pprotest2*100
replace pprotest3=pprotest3*100
replace pprotest4=pprotest4*100
replace pprotest5=pprotest5*100
replace eprotest1=eprotest1*100
replace eprotest2=eprotest2*100
replace eprotest3=eprotest3*100
replace eprotest4=eprotest4*100
replace eprotest5=eprotest5*100

graph bar off1 off2 off3 off4 off5, blabel(bar, ///
position(center) size(medium) format(%8.2f) color(white)) stack legend(off) ///
bar(1, bcolor(black*.8) lcolor(white)) ///
bar(2, bcolor(black*.6) lcolor(white)) ///
bar(3, bcolor(black*.4) lcolor(white)) ///
bar(4, bcolor(black*.2) lcolor(white)) ///
bar(5, bcolor(black) lcolor(white)) ///
title("Governance") ///
subtitle("Officers from the Tunisian military" "should serve in the government", size(medium)) ///
text(5 50 "Strongly disagree", size(medium) color(white)) ///
text(32 50 "Disagree", size(medium) color(white)) ///
text(54 50 "Agree", size(medium) color(white)) ///
text(77 50 "Strongly agree", size(medium) color(white))
graph save off, replace
graph bar pprotest1 pprotest2 pprotest3 pprotest4 pprotest5, blabel(bar, ///
position(center) size(medium) format(%8.2f) color(white)) stack legend(off) ///
bar(1, bcolor(black*.8) lcolor(white)) ///
bar(2, bcolor(black*.6) lcolor(white)) ///
bar(3, bcolor(black*.4) lcolor(white)) ///
bar(4, bcolor(black*.2) lcolor(white)) ///
bar(5, bcolor(black) lcolor(white)) ///
title("Policing 1") ///
subtitle("The military should contribute" "to policing political demonstrations", size(medium)) ///
text(5 50 "Strongly disagree", size(medium) color(white)) ///
text(26 50 "Disagree", size(medium) color(white)) ///
text(52 50 "Agree", size(medium) color(white)) ///
text(79 50 "Strongly agree", size(medium) color(white))
graph save pprotest, replace
graph bar eprotest1 eprotest2 eprotest3 eprotest4 eprotest5, blabel(bar, ///
position(center) size(medium) format(%8.2f) color(white)) stack ///
bar(1, bcolor(black*.8) lcolor(white)) ///
bar(2, bcolor(black*.6) lcolor(white)) ///
bar(3, bcolor(black*.4) lcolor(white)) ///
bar(4, bcolor(black*.2) lcolor(white)) ///
bar(5, bcolor(black) lcolor(white)) ///
title("Policing 2") ///
subtitle("The military should contribute" "to policing economic protests", size(medium)) legend(off) ///
text(5 50 "Strongly disagree", size(medium) color(white)) ///
text(24 50 "Disagree", size(medium) color(white)) ///
text(53 50 "Agree", size(medium) color(white)) ///
text(79 50 "Strongly agree", size(medium) color(white))
graph save eprotest, replace
graph combine off.gph pprotest.gph eprotest.gph, col(3)

********************************************************************************
***Models***********************************************************************
********************************************************************************

***Role expansion scale?
alpha o_officers o_pprotest o_eprotest, i
***Alpha is 0.7140
capture drop expansion_i
egen expansion_i=rowmean(o_officers o_pprotest o_eprotest)
tab expansion_i
label var expansion_i "Attitudes on Military Expansion"
***Protest policing scale?
alpha o_pprotest o_eprotest, i
***Alpha is 0.7476
capture drop expansion_p
egen expansion_p=rowmean(o_pprotest o_eprotest)
tab expansion_p
label var expansion_p "Attitudes on Protest Policing"

*** Figures 4a through 4c ******************************************************

*Ariana, Ben Arous, Bizerte, Manouba, Tunis are greater Tunis
gen gr_tunis=(region=="a" | region=="c" | region=="d" | region=="m" | region=="w")
*Mahdia, Monastir, Sousse, Nabeul, and Sfax are Sahel
gen sahel=(region=="l" | region=="o" | region=="t" | region=="p" | region=="q")
*Beja, Jendouba, Le Kef, Siliana, and Zaghouan are North West
gen nw=(region=="b" | region=="g" | region=="k" | region=="s" | region=="x")
*Gafsa, Kairouan, Kasserine, and Sidi Bou Zid are Center 
gen center=(region=="f" | region=="h" | region=="i" | region=="r")
*Tozeur, Tataouine, Mednine, Kebili, and Gabes are South
gen south=(region=="v" | region=="u" | region=="n" | region=="j" | region=="e")
label var south "South"
label var center "Center"
label var nw "Northwest"

set scheme lean2

set more off
regress expansion_i ///
nidaa ///
nahda ///
non_voter ///
socec_d ///
organized ///
ProtestorRevolution ///
MilitaryService ///
south center nw ///
low_inc med_inc ///
elem_edu sec_edu ///
Female age if age>1, robust
outreg2 using l.doc, replace label
coefplot, levels(90) xline(0) drop(_cons) ///
title("Legislative (Linear)") ///
ylabel(, labsize(large)) ///
xlabel(, labsize(large)) ///
grid(none)
graph save index_l, replace

set more off
ologit o_officers ///
nidaa ///
nahda ///
non_voter ///
socec_d ///
organized ///
ProtestorRevolution ///
MilitaryService ///
south center nw ///
low_inc med_inc /// ///
elem_edu sec_edu ///
Female age if age>1, robust or 
outreg2 using l.doc, label eform append
coefplot, levels(90) xline(1) drop(_cons) ///
eform ///
title("Legislative (OL)") ///
ylabel(, labsize(large)) ///
xlabel(, labsize(large)) ///
grid(none)
graph save officers_l, replace
set more off
margins, predict(outcome(3)) at(non_voter==0) atmeans
margins, predict(outcome(3)) at(non_voter==1) atmeans


set more off
ologit expansion_p ///
nidaa ///
nahda ///
non_voter ///
socec_d ///
organized ///
ProtestorRevolution ///
MilitaryService ///
south center nw ///
low_inc med_inc ///
elem_edu sec_edu ///
Female age if age>1, robust or 
outreg2 using l.doc, label eform append
coefplot, levels(90) xline(1) drop(_cons) ///
eform ///
title("Legislative (OL)") ///
ylabel(, labsize(large)) ///
xlabel(, labsize(large)) ///
grid(none)
graph save iprotest_l, replace
set more off
margins, predict(outcome(3)) at(non_voter==0) atmeans
margins, predict(outcome(3)) at(non_voter==1) atmeans


****Models with presidential elections
graph set window fontface "Times New Roman"

set more off
regress expansion_i ///
essebsi ///
non_voter_p ///
socec_d ///
organized ///
ProtestorRevolution ///
MilitaryService ///
south center nw ///
low_inc med_inc ///
elem_edu sec_edu ///
Female age if age>1, robust
outreg2 using p.doc, replace label
coefplot, levels(90) xline(0) drop(_cons) ///
title("Presidential (Linear)") ///
ylabel(, labsize(large)) ///
xlabel(, labsize(large)) ///
grid(none)
graph save index_p, replace

set more off
ologit o_officers ///
essebsi ///
non_voter_p ///
socec_d ///
organized ///
ProtestorRevolution ///
MilitaryService ///
south center nw ///
low_inc med_inc ///
elem_edu sec_edu ///
Female age if age>1, robust or
outreg2 using p.doc, append eform label
coefplot, levels(90) xline(1) drop(_cons) ///
eform ///
title("Presidential (OL)") ///
ylabel(, labsize(large)) ///
xlabel(, labsize(large)) ///
grid(none)
graph save officers_p, replace
set more off
margins, predict(outcome(3)) at(non_voter_p==0) atmeans
margins, predict(outcome(3)) at(non_voter_p==1) atmeans


set more off
ologit expansion_p ///
essebsi ///
non_voter_p ///
socec_d ///
organized ///
ProtestorRevolution ///
MilitaryService ///
south center nw  ///
low_inc med_inc ///
elem_edu sec_edu ///
Female age if age>1, robust or
outreg2 using p.doc, append eform label
coefplot, levels(90) xline(1) drop(_cons) ///
eform ///
title("Presidential (OL)") ///
ylabel(, labsize(large)) ///
xlabel(, labsize(large)) ///
grid(none)
graph save iprotest_p, replace
set more off
margins, predict(outcome(3)) at(non_voter_p==0) atmeans
margins, predict(outcome(3)) at(non_voter_p==1) atmeans

graph combine index_l.gph index_p.gph, row(1) 
graph save RoleExpansion.png, replace
graph combine officers_l.gph officers_p.gph, row(1) 
graph save Officers.png, replace
graph combine iprotest_l.gph iprotest_p.gph, row(1) 
graph save Policing.png, replace

***Figures 5 and 6**************************************************************

set more off
ologit OrderedMilFightTerror ///
nidaa ///
nahda ///
non_voter_p ///
socec_d ///
organized ///
ProtestorRevolution ///
MilitaryService ///
south center nw  ///
low_inc med_inc /// ///
elem_edu sec_edu ///
Female age if age>1, or r
outreg2 using placebo.doc, eform label replace
coefplot, levels(90) xline(1) drop(_cons) ///
eform ///
title("Legislative (OL)") ///
ylabel(, labsize(large)) ///
xlabel(, labsize(large)) ///
grid(none)
graph save placebo1l, replace

set more off
ologit OrderedMilForeignPeaceKeeping ///
nidaa ///
nahda ///
non_voter_p ///
socec_d ///
organized ///
ProtestorRevolution ///
MilitaryService ///
south center nw  ///
low_inc med_inc /// ///
elem_edu sec_edu ///
Female age if age>1, or r
outreg2 using placebo.doc, eform label append
coefplot, levels(90) xline(1) drop(_cons) ///
eform ///
title("Legislative (OL)") ///
ylabel(, labsize(large)) ///
xlabel(, labsize(large)) ///
grid(none)
graph save placebo2l, replace

set more off
ologit OrderedMilFightTerror ///
essebsi ///
non_voter_p ///
socec_d ///
organized ///
ProtestorRevolution ///
MilitaryService ///
south center nw  ///
low_inc med_inc /// ///
elem_edu sec_edu ///
Female age if age>1, or r
outreg2 using placebo.doc, eform label append
coefplot, levels(90) xline(1) drop(_cons) ///
eform ///
title("Presidential (OL)") ///
ylabel(, labsize(large)) ///
xlabel(, labsize(large)) ///
grid(none)
graph save placebo1p, replace

set more off
ologit OrderedMilForeignPeaceKeeping ///
essebsi ///
non_voter_p ///
socec_d ///
organized ///
ProtestorRevolution ///
MilitaryService ///
south center nw  ///
low_inc med_inc /// ///
elem_edu sec_edu ///
Female age if age>1, or r
outreg2 using placebo.doc, eform label append
coefplot, levels(90) xline(1) drop(_cons) ///
eform ///
title("Presidential (OL)") ///
ylabel(, labsize(large)) ///
xlabel(, labsize(large)) ///
grid(none)
graph save placebo2p, replace

graph combine placebo1l.gph placebo1p.gph, row(1) 
graph combine placebo2l.gph placebo2p.gph, row(1) 

********************************************************************************
*** Appendix *******************************************************************
********************************************************************************

***Partial Proportional Odds Models (Robustness)

*** Brant tests for all models
set more off
ologit o_officers ///
nidaa ///
nahda ///
non_voter ///
socec_d ///
organized ///
ProtestorRevolution ///
MilitaryService ///
south center nw ///
low_inc med_inc /// ///
elem_edu sec_edu ///
Female age if age>1, robust 
oparallel 
** Brant test: p=0.066
set more off
ologit expansion_p ///
nidaa ///
nahda ///
non_voter ///
socec_d ///
organized ///
ProtestorRevolution ///
MilitaryService ///
south center nw ///
low_inc med_inc ///
elem_edu sec_edu ///
Female age if age>1, robust 
oparallel 
** Brant test: p=0.704

****Models with presidential elections
set more off
ologit o_officers ///
essebsi ///
non_voter_p ///
socec_d ///
organized ///
ProtestorRevolution ///
MilitaryService ///
south center nw ///
low_inc med_inc ///
elem_edu sec_edu ///
Female age if age>1, robust 
oparallel 
** Brant test: p=0.103

set more off
ologit expansion_p ///
essebsi ///
non_voter_p ///
socec_d ///
organized ///
ProtestorRevolution ///
MilitaryService ///
south center nw  ///
low_inc med_inc ///
elem_edu sec_edu ///
Female age if age>1, robust 
oparallel
** Brant test: p=0.538

*** respecifying model 2 as PPO
set more off
gologit2 o_officers ///
nidaa ///
nahda ///
non_voter ///
socec_d ///
organized ///
ProtestorRevolution ///
MilitaryService ///
south center nw  ///
low_inc med_inc ///
elem_edu sec_edu ///
Female age if age>1, or robust autofit
outreg2 using ppo.doc, replace eform label
 
***substantively similar results, PO assumption violated only for inc variables


